#include <iostream>
#include<vector>
using namespace std;

int main() 
{
    int n = 0, m = 0;
    cin >> n >> m;
    vector<vector<char>> grid(n, vector<char>(m));
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> grid[i][j];
        }
    }
    int hash[26] = {0};
    hash[4] = 1; hash[11] = 4; hash[14] = 3; hash[21] = 2;
    
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + hash[(grid[i-1][j-1]-'a')];
        }
    }
    cout << dp[n][m] << endl;
}